#include <iostream>
#include <string>
#include <vector>

size_t split(const std::string &str, const std::string &sep, std::vector<std::string> &result)
{
    // animal...dog..leg. sep = '.'
    int pos = 0,index = 0;
    while(index<str.size())
    {
        pos = str.find(sep,index);
        if(pos==std::string::npos)
        {
            result.emplace_back(str.substr(index));
            return result.size();
        }
        if(pos!=index)
        {
            result.emplace_back(str.substr(index,pos-index));
            index = pos + sep.size();
            continue;
        }
        index += sep.size();
    }
    return result.size();
}

int main()
{
    std::string str = "...news...music.#.pop...";
    std::vector<std::string> arr;
    int n = split(str,".",arr);
    for(auto& e : arr)
    {
        std::cout<<e<<std::endl;
    }
    return 0;
}